<% import grails.persistence.Event %>
<% import org.codehaus.groovy.grails.plugins.PluginManagerHolder %>
<%=packageName%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
  <g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
  <title><g:message code="default.create.label" args="[entityName]" /></title>
</head>
<body>
  <ul class="nav">
    <li><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
    <li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></li>
  </ul>
  <div class="body">
    <h1><g:message code="default.create.label" args="[entityName]" /></h1>
    <g:if test="\${flash.message}">
          <div class="message">\${flash.message}</div>
</g:if>
<g:hasErrors bean="\${${propertyName}}">
  <div class="errors">
    <g:renderErrors bean="\${${propertyName}}" as="list" />
  </div>
</g:hasErrors>
<g:form action="save" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
  <div class="dialog">
<%  excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
persistentPropNames = domainClass.persistentProperties*.name
props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
display = true
boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
props.each { p ->
  if (!Collection.class.isAssignableFrom(p.type)) {
    if (hasHibernate) {
      cp = domainClass.constrainedProperties[p.name]
      display = (cp ? cp.display : true)
    }
    if (display) { %>
    <div class="campo">
      <label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" />:
        <span class="value \${hasErrors(bean: ${propertyName}, field: '${p.name}', 'errors')}">
      ${renderEditor(p)}
        </span>
      </label>
    </div><!-- end .campo -->
      <%  }   }   } %>
  </div><!-- end .dialog -->
  <div class="clear"><!-- clear element --></div>
  <div class="buttons">
    <span class="button"><g:submitButton name="create" class="save" value="\${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                                         </div><!-- end .buttons -->
                                         </g:form>
                                         <div class="clear"><!-- clear element --></div>
                                         </div><!-- end .body -->
                                         </body>
                                         </html>
